<?php
namespace app\admin\controller\direct;

use app\common\controller\Backend;
use app\common\model\direct\OrderModel;
use think\Request;

class Order extends Backend
{
    public function index(){
        return view();
    }
    public  function getDataList($startDay,$endDay,$page=1){
        $orderModel = new OrderModel();
        $startTime  = strtotime($startDay." 0:0:0");
        $endTime  = strtotime($endDay." 23:59:59");
        $allPage = ceil($orderModel->where('create_time','between',[$startTime,$endTime])->count()/10);
        $dataList = $orderModel->where('create_time','between',[$startTime,$endTime])
            ->with(['creator','beyond','store'])
            ->page($page,10)
            ->order("create_time","desc")
            ->select();
        foreach ($dataList as &$data){
            $data['status_ch'] = $orderModel->getStatusCh($data['status']);
            $data['create_time_ch'] = date("Y-m-d H:i:s",(int)$data['create_time']);
            $data['update_time_ch'] = date("Y-m-d H:i:s",(int)$data['update_time']);
        }
        $retData['dataList']=$dataList;
        $retData['allPage']=$allPage;
        return json(['status'=>1,'data'=>$retData]);
    }
    public function modifyRemark($id,$remark){
        $orderModel = new OrderModel();
        $order=$orderModel->find($id);
        $order->update_time=time();
        $order->remark=$remark;
        $order->save();
        return json(['status'=>1]);
    }
}